package xyz.labradormm.auth.util;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.yaml.snakeyaml.Yaml;

import java.io.InputStream;
import java.util.Map;

public class YamlConfigLoader {

    private static final String YAML_CONFIG_FILE = "application-dev.yml";

    public static JSONObject loadYamlConfig() {
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        InputStream input = classLoader.getResourceAsStream(YAML_CONFIG_FILE);
        if (input == null) {
            throw new RuntimeException("Unable to find the YAML configuration file '" + YAML_CONFIG_FILE + "'");
        }

        Yaml yaml = new Yaml();
        Map<String,Object> map=yaml.load(input);
        return JSON.parseObject(JSON.toJSONString(map));
    }



}
